package com.hcss.common.util.excel.rull;


/**
 * @Title:
 * @Description: 主要是为了Excel列数与Excel中标号的转换
 * @Author:momo
 * @Since:2019年1月29日
 * @Version:1.1.0
 */
public class ColIndexName {
	
	public static String toIndexMain(int x) throws Exception {
		if(x < 0) {
			throw new Exception("参数不能为负数！");
		}
		return toIndex(x);
	}
	
	private static String toIndex(int x) throws Exception{
        if (x < 0)
        	return "";
        int a = x / 26;
        int b = x % 26;
        return toIndex(a - 1) + (char)(b + 'A');
    }
	
    public static void main(String[] args) throws Exception {
		System.out.println(toIndexMain(26));
		System.out.println(toIndexMain(27));
		System.out.println(toIndexMain(28));
		System.out.println(toIndexMain(1));
		System.out.println(toIndexMain(2));
		System.out.println(toIndexMain(3));
	}
	
	
}

    